package org.example.ctsbocc.controller;

import jakarta.annotation.Resource;
import org.example.ctsbocc.entity.Project;
import org.example.ctsbocc.service.ProjectService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/project")
public class ProjectController {

    @Resource(name = "projectService")
    private ProjectService projectService;
    private static final Logger logger = LoggerFactory.getLogger("org.example.ctsbocc.business");

    @PostMapping("/findByOwner")
    @ResponseBody
    public List<Project> findByOwner(String gitRepoOwner) {
        if(gitRepoOwner == null) {
            gitRepoOwner = "ownerTest1";
        }

        logger.info("findByOwner: {}", gitRepoOwner);

        return projectService.findByOwner(gitRepoOwner);
    }
}
